package ink.metoo.auto.fishpi.call

import ink.metoo.auto.fishpi.ClientCaches

object CsrfCall {

    fun getCsrfToken(): String? {
        // 无这个路径, 仅通过返回的是404页面拿csrfToken
        val html = Requests.sendGetRequest<String>(
            "/csrf",
            queryParams = arrayOf(
                "apiKey" to ClientCaches.apiKey
            )
        )
        return """csrfToken:\s*['"]([^'"]*)['"]""".toRegex().find(html)?.groupValues?.get(1)
    }

}
